package com.yeung.exam;

import java.util.Arrays;
import java.util.Scanner;

public class ReadUtils {
    public static void main(String[] args) {
//        连续读取两组数据();
//        从控制台读取指定组数据();
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if (line.equals("0")) break;
            long[] numbers = str2Long(line, " ");
            long[] newNumbers = Arrays.copyOfRange(numbers, 1, numbers.length);
            long sum = 0l;
            for (long number : newNumbers) {
                sum += number;
            }
            System.out.println(sum);

        }

    }

    /**
     * 出题人的陷阱
     * // 不要用 int a, b, 因为测试数据会越界，为了效果，所以这个题目故意不在题面说数据范围
     * // 你可以试试测试用例 12141483647 12141483647，输出结果是否正确
     * <p>
     * 本地可以通过, 但是线上过不了有可能时因为接收的数据不对, 或太大了
     * <p>
     * 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
     */
    public static void 谨防数据越界() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLong()) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(a + b);
        }
    }

    /**
     * 1 5
     * 10 20
     * 0 0
     * 如果输入为0 0则结束输入
     */
    public static void 一直读取直到限定条件() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (a == 0 && b == 0)
                break;
            System.out.println(a + b);
        }
    }

    /**
     * 1 5
     * 10 20
     */
    public static void 连续读取两组数据() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int i = scanner.nextInt();
            int i1 = scanner.nextInt();
            System.out.println(i + i1);
        }
    }

    /**
     * 2
     * 1 5
     * 10 20
     * <p>
     * 注意多组测试数据, 一定是读取一组数据之后, 就要输出一组数据的结果, 不能到最后一块输出, 会编译不通过
     */
    public static void 从控制台读取指定组数据() {
        Scanner scanner = new Scanner(System.in);
        Integer groups = Integer.valueOf(scanner.nextLine());
        while (groups > 0) {
            String[] split = scanner.nextLine().split(" ");
            int numbers[] = new int[split.length];
            int index = 0;
            while (index < split.length) {
                numbers[index] = Integer.valueOf(split[index]);
                index++;

            }
            System.out.println(getSum(numbers));
            groups--;
        }

    }

    private static int getSum(int[] numbers) {
        int sum = 0;
        for (int number : numbers) {
            sum += number;
        }
        return sum;
    }


    public static int[] str2Int(String line, String sperator) {
        String[] split = line.split(sperator);
        int[] temp = new int[split.length];
        for (int i = 0; i < temp.length; i++) {
            temp[i] = Integer.parseInt(split[i]);
        }
        return temp;

    }

    public static long[] str2Long(String line, String sperator) {
        String[] split = line.split(sperator);
        long[] temp = new long[split.length];
        for (int i = 0; i < temp.length; i++) {
            temp[i] = Long.parseLong(split[i]);
        }
        return temp;

    }

}
